﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>订单信息</title>
    <!--<link href="../../script/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../script/css/bootstrap-table.css" rel="stylesheet" />
    <script src="../../script/js/jquery-1.12.3.js"></script>
    <script src="../../script/js/bootstrap.min.js"></script>
    <script src="../../script/js/bootstrap-table.js"></script>
    <script src="../../script/js/bootstrap-table-zh-CN.js"></script>
    <script src="../../script/js/cus-grid.js"></script>-->
</head>
<body>
    <div style="width:100%">
        <table name="order_main"></table>
    </div>
    <script name="loadPage">
        var order_main_init;

        var order_main = {
            data: {
                data: []
            },
            detailLink: [],
            rowbtns: [],
            toolbtns: [],
            cols: [],
            new: function () {
                order_main_init.editLoad('order_main_edit.html');
            },
            edit: function () {
                order_main_init.editLoad('order_main_edit.html');
            },
            del: function () {
                $.post('/api/order_main/del', { id: order_main_init.getId_edit }, function () {
                    window.location.reload();
                });
            },
            mdel: function () {
                $.post('/api/order_main/mdel', { objs: order_main_init.getSelects() }, function () {
                    window.location.reload();
                });
            },
            check: function () {

            },
            mcheck: function () {

            },
            th: function () {
                $.post('/api/order_main/wlth', { id: order_main_init.getId_edit }, function () {
                    window.location.reload();
                });
            }
        };

        $(function () {
            order_main.cols = [
{ field: 'code', title: '单号' }
, {
    field: 'companyid1', title: '货主', formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['companyid1'].length; i++) {
            var p = order_main.data['companyid1'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, {
    field: 'companyid2', title: '提货方', formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['companyid2'].length; i++) {
            var p = order_main.data['companyid2'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, { field: 'contact', title: '联系人' }
, { field: 'mobile', title: '联系电话' }
, { field: 'remobile', title: '备用联系电话', visible: false }
, { field: 'company2', title: '公司', visible: false }
, { field: 'address', title: '地址', visible: false }
, { field: 'arrivedate', title: '到货日期', visible: false }
, {
    field: 'type', title: '物流要求', formatter: function (val, row, idx) {
        var str = '';
        var k = -1;
        for (var i = 0; i < order_main.data['type'].length; i++) {
            var p = order_main.data['type'][i];
            var j = (',' + val + ',').indexOf(',' + p.id + ',');
            if (j >= 0) {
                if (j > k) {
                    str = str == '' ? p.text : str + ',' + p.text;
                } else {
                    str = str == '' ? p.text : p.text + ',' + str;
                }
                k = j;
            }
        }
        return str;
    }
}
, { field: 'name', title: '货物名称', visible: false }
, {
    field: 'type2', title: '货物种类', visible: false, formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['type2'].length; i++) {
            var p = order_main.data['type2'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, { field: 'weight', title: '总重（吨）', visible: false }
, { field: 'volume', title: '体积（方）', visible: false }
, {
    field: 'barea', title: '提货地点', visible: false, formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['barea'].length; i++) {
            var p = order_main.data['barea'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, {
    field: 'earea', title: '目的地', visible: false, formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['earea'].length; i++) {
            var p = order_main.data['earea'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, { field: 'tolvalue', title: '货物总价', visible: false }
, {
    field: 'iflag', title: '状态', visible: false, formatter: function (val, row, idx) {
        var str = '';
        for (var i = 0; i < order_main.data['iflag'].length; i++) {
            var p = order_main.data['iflag'][i];
            if (p.id == val) {
                str = str == '' ? p.text : str + ',' + p.text;
            }
        }
        return str;
    }
}
, { field: 'filler', title: '最后更新人', visible: false }
, { field: 'filldate', title: '最后更新时间', visible: false }
, { field: 'remark', title: '备注', visible: false }
            ];

            order_main.rowbtns.push({
                text: '查看',
                fn: 'order_main.edit'
            });
            order_main.rowbtns.push({
                text: '物流公司提货',
                fn: 'order_main.th'
            });
            //order_main.rowbtns.push({
            //    text: '删除',
            //    fn: 'order_main.del'
            //});
            //order_main.rowbtns.push({
            //    jstr: '<button class="btn btn-danger" onclick="order_main.check();">审核</button>'
            //});

            //order_main.toolbtns.push({
            //    text: '新增',
            //    fn: 'order_main.new'
            //});
            //order_main.toolbtns.push({
            //    text: '删除',
            //    fn: 'order_main.mdel'
            //});
            //order_main.toolbtns.push({
            //    jstr: '<button class="btn btn-danger" onclick="order_main.mcheck();">审核</button>'
            //});

            order_main.detailLink.push({
                tablename: 'order_account_hz',
                parentid: 'id',
                caption: '客户收付款',
                isActive: true
            });
            //order_main.detailLink.push({
            //    tablename: 'order_account_wl',
            //    parentid: 'id',
            //    caption: '物流公司收付款',
            //    isActive: false
            //});
            order_main.detailLink.push({
                tablename: 'order_line',
                parentid: 'id',
                caption: '运输情况',
                isActive: false
            });

            order_main_init = order_main_init == undefined ? cusGrid() : function () {
                return order_main_init.reCreate();
            }();
            $.get('/api/order_main/get',
null,
                    function (data) {
                        order_main.data = data;
                        order_main_init.init({
                            data: order_main.data,
                            detailLink: order_main.detailLink,
                            rowbtns: order_main.rowbtns,
                            toolbtns: order_main.toolbtns,
                            cols: order_main.cols,
                            isSelect: true,
                            tableName: 'order_main'
                        });
                        order_main_init.initTable();
                    });
        })
    </script>



</body>
</html>
